import { type MessageParamsWithType } from 'element-plus'

let loadingInstance: any

export default {
  // 消息提示
  msg(content: MessageParamsWithType) {
    ElMessage.info(content)
  },
  // 错误消息
  msgError(content: MessageParamsWithType) {
    ElMessage.error(content)
  },
  // 成功消息
  msgSuccess(content: MessageParamsWithType) {
    ElMessage.success(content)
  },
  // 警告消息
  msgWarning(content: MessageParamsWithType) {
    ElMessage.warning(content)
  },
  // 打开遮罩层
  loading(content: any) {
    loadingInstance = ElLoading.service({
      lock: true,
      text: content,
      background: 'rgba(0, 0, 0, 0.7)',
    })
  },
  // 关闭遮罩层
  closeLoading() {
    loadingInstance.close()
  },
}
